package org.xutils.xutillearn.ui.activity;

import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;
import org.xutils.xutillearn.R;
import org.xutils.xutillearn.bean.LearnListItem;
import org.xutils.xutillearn.presenter.MainPresenter;
import org.xutils.xutillearn.presenter.presenterImpl.MainPresenterImpl;
import org.xutils.xutillearn.ui.adapter.MyAdapter;
import org.xutils.xutillearn.ui.common.BaseActivity;
import org.xutils.xutillearn.ui.iview.IMainView;

import java.util.List;

/**
 * Created by 杨木易 on 2016/3/27.
 */
@ContentView(R.layout.activity_main)
public class MainActivity extends BaseActivity implements IMainView {


    @ViewInject(R.id.toolbar)
    Toolbar toolbar;

    @ViewInject(R.id.recycylerview)
    RecyclerView recyclerView;

    MainPresenter presenter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(linearLayoutManager);
        recyclerView.setItemAnimator(new DefaultItemAnimator());

        presenter = new MainPresenterImpl(this);

    }


    @Override
    protected void onResume() {
        super.onResume();
        presenter.showLessonList();
    }

    @Override
    public void showLessonList(List<LearnListItem> list) {
        RecyclerView.Adapter myAdapter = new MyAdapter(list,this);
        recyclerView.setAdapter(myAdapter);
    }


}
